#pragma  once

#include "FFMpegInstance.h"


class CCodecConverter
{
public:
	CCodecConverter(int codecFrom, int codecTo, BOOL bAudio);
	~CCodecConverter();
	BOOL Init();
	int convertCodec(unsigned char* fromBuf, int inBufSize, unsigned char* toBuf, int outBufSize);

private:
	AVCodec *m_pDecCodec;
	AVCodec *m_pEncCodec;
	int m_nFromCodec;
	int m_nToCodec;
	AVCodecContext *m_pEncContext;
	AVCodecContext *m_pDecContext;
	AVFrame *m_pFrame;
	struct SwsContext* m_pImgConvertCtx;
	BOOL    m_bAudio;
	BOOL SetScaling(int fromW, int fromH, PixelFormat fromPixFmt, int toW, int toH, PixelFormat toPixFmt);
};
